package com.mcptt.config.ue.initial.sub.sub.sub;

import java.util.List;

import org.jdom.Element;
import org.jdom.JDOMException;

import com.cloudptt.api.product.log.Log;

public class Service {
	public static final String Name = "service";
	private static final String Name_McpttToConRef = "MCPTT-to-con-ref";
	private static final String Name_McCommonCoreToConRef = "MC-common-core-to-con-ref";
	private static final String Name_McIdToConRef = "MC-ID-to-con-ref";
	
	private String mcpttToConRef = null;
	private String mcCommonCoreToConRef = null;
	private String mcIdToConRef = null;
	
	public void parse(Element elem) throws JDOMException
	{
		if(elem == null)
		{
			return;
		}
		List<Element> list = elem.getChildren();//��ø��ڵ���ӽڵ�  
		for(Element subElem:list) 
		{
			String name = subElem.getName();
			Log.debug(this.getClass(), "name = " + name);
			
			if(name == null
					|| name.length() <= 0)
			{
				return;
			}
			if(name.equals(Name_McpttToConRef))
			{
				mcpttToConRef = subElem.getText();
			}
			else if(name.equals(Name_McCommonCoreToConRef))
			{
				mcCommonCoreToConRef = subElem.getText();
			}
			else if(name.equals(Name_McIdToConRef))
			{
				mcIdToConRef = subElem.getText();
			}
		}  
	}
	
	public String toString()
	{
		StringBuffer strBuf = new StringBuffer("\r\n");
		strBuf.append("<").append(Name).append(">").append("\r\n");
		strBuf.append("    ").append("<").append(Name_McpttToConRef).append(">");
		strBuf.append(mcpttToConRef);
		strBuf.append("</").append(Name_McpttToConRef).append(">").append("\r\n");
		strBuf.append("    ").append("<").append(Name_McCommonCoreToConRef).append(">");
		strBuf.append(mcCommonCoreToConRef);
		strBuf.append("</").append(Name_McCommonCoreToConRef).append(">").append("\r\n");
		strBuf.append("    ").append("<").append(Name_McIdToConRef).append(">");
		strBuf.append(mcIdToConRef);
		strBuf.append("</").append(Name_McIdToConRef).append(">").append("\r\n");
		strBuf.append("</").append(Name).append(">").append("\r\n");

		return strBuf.toString();
	}
}
